import socket
import configset
import traceback

dataconf = configset.read_config()
HOST = dataconf.setting[0].debug_server
PORT =dataconf.setting[0].debug_server_port

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
server_address = (HOST,int(PORT))

def sendlog(msg):
    if isinstance(msg, list):
        try:
            sock.sendto(str(msg),server_address)
            #sock.close()
        except:
            import e_login
            datae = str(traceback.format_exc())
            #e_login.main("error","error send log error to server debug",str(datae))
            print datae
            sock.close()
    else:
        datae = str(traceback.format_exc())
        e_login.main('error','error send log message error to server debug',datae)
        
def conn_close():
    try:
        sock.close()
    except:
        import e_login
        datae = str(traceback.format_exc())
        e_login.main('error','error send log error to server debug',datae)
        sock.close()
        
#if __name__ == "__main__":
#    msg = ['error','test error by me ']
#    sendlog(msg)

